package com.karaku.karaku_collector.collector;

import com.karaku.karaku_collector.common.BaseApi;
import com.karaku.karaku_collector.common.http.JsonFinder;
import com.karaku.karaku_collector.common.http.NetCallback;
import com.karaku.karaku_collector.common.http.NetOperation;
import com.karaku.karaku_collector.collector.model.DynamicKey;

/**
 * Created by guoping on 2017/10/26.
 */

public class CollectorApi extends BaseApi {
    public static NetOperation getDynamicKey(String roomId, NetCallback<DynamicKey> callback) {
        NetOperation<DynamicKey> o = new NetOperation<>("collector/getDynamicKey", createParams(
                "roomId", roomId
        ));
        o.post(DynamicKey.class, callback);
        return o;
    }

    public static NetOperation uploadRoomInfo(String roomId, int direction, int uid, NetCallback<Void> callback) {
        NetOperation<Void> o = new NetOperation<>("collector/setInfo", createParams(
                "roomId", roomId,
                "direction", direction,
                "agoraUid", uid
        ));
        o.post(Void.class, callback);
        return o;
    }

    public static NetOperation heartbeat(HeartbeatManager.HeartbeatModel heartbeatModel, NetCallback<Void> callback) {
        NetOperation<Void> o = new NetOperation<>("collector/heartbeat", createParams(
                "info", JsonFinder.getGson().toJson(heartbeatModel)
        ));
        o.post(Void.class, callback);
        return o;
    }
}
